var mongoose = require('mongoose');

let dbUser = require('./schemaUser');

var db = mongoose.connect('mongodb://127.0.0.1/chat20170719',
    {
        useMongoClient: true,
        promiseLibrary: require('q').Promise//global.Promise //require('bluebird') //
    });//；连接数据库
var dbConnected = false;

db.on("error", function (error) {
    console.log("数据库连接失败：" + error);
    dbConnected = false;
});
db.on("open", function () {
    console.log("------数据库连接成功！------");
    // var x = test('aaaaaaaa');
    dbConnected = true;
});

db.once("open", dbUser.initUser);

